Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classnames

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classnames

A simple utility for conditionally joining classNames together

  • 2.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13M
increased by1.25%
Maintainers
2
Weekly downloads
 
Created

What is classnames?

The classnames package is a simple utility for conditionally joining class names together. It is commonly used in React projects but can be used anywhere that requires dynamic class name computation.

What are classnames's main functionalities?

String arguments

Combine multiple string arguments into one class name.

classnames('foo', 'bar'); // 'foo bar'

Object arguments

Use an object to include class names conditionally based on the truthiness of the object's values.

classnames({ 'foo': true, 'bar': false }); // 'foo'

Array arguments

Pass an array of class names which will be joined together.

classnames(['foo', 'bar']); // 'foo bar'

Mixed arguments

Combine string, object, and array arguments to form a class name string.

classnames('foo', { 'bar': true, 'duck': false }, ['baz', { 'quux': true }]); // 'foo bar baz quux'

Other packages similar to classnames

Keywords

FAQs

Package last updated on 29 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc